package com.lyj.sc.Design;

/**
 * @Author: liyangjing
 * @Date: 2022/03/24/14:41
 * @Description:
 */
public class Singleton {
    private volatile static Singleton singleton;

    private Singleton() {

    }
//静态方法
    public static Singleton newInstance(){
        if(singleton==null){
            //锁住这个类
            synchronized (Singleton.class){
                if(singleton==null){
                    singleton=new Singleton();
                }
            }
        }
        return singleton;
    }
}
